package com.atguigu.bigdata.scala.chapter11

import com.atguigu.bigdata.scala.chapter11.Scala05_Generic.Parent

object Scala05_Generic {

    def main(args: Array[String]): Unit = {
        // TODO - 泛型 - scala
        val list : List[Int] = List(1,2,3,4)

        // (A1, A1) => A1
        // (Int, Int) => Int
        // Any,AnyVal >: Int
        //list.reduce()

        val list1 : List[User] = List[User](
            new User(), new User(), new User()
        )
        // Parent >: User
        val user: User = list1.reduce((x, y) => x)
        //val child: Child = list1.reduce[Child]((x, y) => x)
        val parent: Parent = list1.reduce[Parent]((x, y) => x)
        //A在list1创建时赋值为User A1范围大于A 父类范围大 所以A1是A的父类,所以list1.reduce[Parent]((x, y) => x)对
        //def reduce[A1 >: A](op: (A1, A1) => A1): A1 = reduceLeft(op)
        println(parent)

    }
    class Parent {

    }
    class User extends Parent{

    }
    class Child extends User {

    }
}
